Skip to content

Update ahn.py#370

Merged
rubencalje merged 3 commits intodevfrom
improve_ahn
Sep 19, 2024
Merged

Update ahn.py#370
rubencalje merged 3 commits intodevfrom
improve_ahn

Conversation

@rubencalje
Copy link
Collaborator

@rubencalje rubencalje commented Sep 18, 2024

This PR fixes issues #367 and #369, by adding support to AHN 5, and implementing a different way to retrieve the ahn-data.

This PR changes the way we retrieve the AHN data for all AHN-versions, to use the Ellipsis Drive (described in https://www.ahn.nl/dataroom).

get_ahn1, get_ahn2, get_ahn3 and get_ahn4 have been renamed to get_ahn1_legacy, get_ahn2_legacy, get_ahn3_legacy and get_ahn4_legacy, mainly so the user can test if the same output is returned by the new methods: new versions of get_ahn1, get_ahn2, get_ahn3, get_ahn4 and get_ahn5 have been implemented that use the files from Ellipsis Drive. These methods will always return a xarray DataArray, so the use of the as_data_array-argument has been deprecated. Because the merging of the different tiles now takes place at the rioxarray-level (and not at the rasterio-level), the bug described in #369 is solved.

The identifier-argument on the ellipsis-drive (which determines the resolution of the downloaded data and if a DTM or DSM is downloaded) is a bit different from the ones we used to use. Some logic has been implemented, so the new methods should also work with the old identifier-names.

AHN3: 'AHN3_05m_DSM', 'AHN3_05m_DTM', 'AHN3_5m_DSM' or 'AHN3_5m_DTM'
AHN4: 'AHN4_DTM_05m', 'AHN4_DTM_5m', 'AHN4_DSM_05m' or 'AHN4_DSM_5m'
The default is 'AHN4_DTM_5m'.
AHN1: 'AHN1_5M'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add explanation of M and R :)

if not r.ok:
raise (HTTPError(f"Request not successful: {r.url}"))
gdf = gpd.GeoDataFrame.from_features(r.json()["result"]["features"], crs=4326)
gdf = gdf.to_crs(crs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transform here is happening using EPSG 28992, not our custom definition. Are we sure things are ending up in the right spot in NL?

extent
identifier : TYPE, optional
identifier : str, optional
Possible values are 'AHN2_05M_I', 'AHN2_05M_N', 'AHN2_05M_R' and
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explain differences between suffixes?

Copy link
Collaborator

@dbrakenhoff dbrakenhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about the transform from EPSG4326 to EPSG28992, whether that is currently correct, as compared to our background map methods?

For the rest some guidance on which identifier corresponds to which AHN product would be nice.

Otherwise looks good, so approving this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants